<?php

namespace App\Admin\Renderables\Ddb;

use App\Models\DdbFirst;
use App\Models\DdbFirstStatistic;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class StatisticRenderTable extends LazyRenderable
{
    public function grid(): Grid
    {
        $builder = DdbFirstStatistic::query()->orderBy('dwdm');
        return Grid::make($builder, function (Grid $grid) {
            $grid->column('dwmc', '选举单位')->width('200');
            $grid->column('count', '推荐代表数')->width('120')->display(function(){
                return DdbFirst::where('dwdm', $this->dwdm)->count();
            });
            $grid->column('content', '导入统计内容');
            $grid->paginate(35);
            $grid->disableActions()->disableRowSelector()->disablePagination();
        });
    }
}